package com.fgw.admin.web;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.plugins.Page;
import com.fgw.admin.dto.ResultInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.*;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;

import com.fgw.admin.entity.ProjectTransmit;
import com.fgw.admin.service.IProjectTransmitService;

/**
 * 项目投资下达情况 前端控制器
 *
 * @author system
 * @date 2020-11-18 22:31:50
 */
@Controller
@RequestMapping("/projectTransmit")
public class ProjectTransmitController {
    @Resource
    private IProjectTransmitService iProjectTransmitService;

    @RequestMapping("/*")
    public void toHtml(){

    }

    @RequestMapping("/listData")
    @RequiresPermissions("projectTransmit:view")
    public @ResponseBody
    ResultInfo<List<ProjectTransmit>> listData(ProjectTransmit projectTransmit,@RequestParam(defaultValue="1") Integer page,@RequestParam(defaultValue="10") Integer limit){
        EntityWrapper<ProjectTransmit> wrapper = new EntityWrapper<>(projectTransmit);
        Page<ProjectTransmit> pageObj = iProjectTransmitService.selectPage(new Page<>(page,limit), wrapper);
        return new ResultInfo<>(pageObj.getRecords(), pageObj.getTotal());
    }

    @RequestMapping("/add")
    @RequiresPermissions("projectTransmit:add")
    public @ResponseBody
    ResultInfo<Boolean> add(ProjectTransmit projectTransmit){
        boolean b = iProjectTransmitService.insert(projectTransmit);
        return new ResultInfo<>(b);
    }

    @RequestMapping("/delBatch")
    @RequiresPermissions("projectTransmit:del")
    public @ResponseBody
    ResultInfo<Boolean> delBatch(Integer[] idArr){
        boolean b = iProjectTransmitService.deleteBatchIds(Arrays.asList(idArr));
        return new ResultInfo<>(b);
    }

    @RequestMapping("/edit")
    @RequiresPermissions("projectTransmit:edit")
    public @ResponseBody
    ResultInfo<Boolean> edit(ProjectTransmit projectTransmit){
        boolean b = iProjectTransmitService.updateById(projectTransmit);
        return new ResultInfo<>(b);
    }

}
